package com.bw.mapper;

import com.bw.bean.V2;
import com.bw.bean.Vo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Author: lhy
 * @Date: 2025/3/19 08:47
 * @Description:
 **/
@Mapper
public interface VoMapper {
    @Select("select count(od.order_id) num\n" +
            "from order_info oi\n" +
            "left join order_detail od on oi.id = od.order_id")
    double getList1();
    @Select("select b.org_name,\n" +
            "       sum(tt.actual_distance) value,\n" +
            "       count(tt.id) num,\n" +
            "       sum(hour(tt.actual_end_time) )value1,\n" +
            "       sum(hour(tt.actual_end_time) )/count(tt.id) value2,\n" +
            "       sum(tt.actual_distance)/count(tt.id) value3\n" +
            "from base_organ b\n" +
            "left join express_task_delivery etd on b.id = etd.org_id\n" +
            "left join line_base_info lbi on b.id = lbi.org_id\n" +
            "left join transport_task tt on lbi.id = tt.line_id\n" +
            "left join transport_task_detail ttd on tt.id = ttd.transport_task_id\n" +
            "left join order_info oi on ttd.order_id = oi.id\n" +
            "group by b.org_name having value is not null")

    List<V2> getList2();
    @Select("select b.name name,\n" +
            "       count(b.id) value\n" +
            "from base_region_info b\n" +
            "left join base_organ bo on b.id = bo.region_id\n" +
            "left join line_base_info lbi on bo.id = lbi.org_id\n" +
            "left join transport_task tt on lbi.id = tt.line_id\n" +
            "group by b.name")
    List<Vo> getList3();
}
